#include "stdafx.h"
#include "label.h"


namespace uiwin
{
	Label::Label(Container* parent)
		: Control(parent), 
		text_size_(12), 
		text_color_(0), text_disable_color_(RGB(80, 80, 80))
	{		
	}

	Label::~Label()
	{
		if (text_)
			free(text_);
	}

	void Label::settext(LPCTSTR text)
	{
		if (text_)
			free(text_);

		text_ = _tcsdup(text);
	}


	void Label::PaintText(PaintDC& dc)
	{
		Font font;
		font.CreateFont(_T("Arial"), text_size_);

		dc.DrawText(text_, &rcitem_, DT_LEFT, font, enable_ ? text_color_ : text_disable_color_, TRUE);

// 		
// 		HFONT oldfont = dc.SelectFont(font);
// 		COLORREF oldcolor = dc.SetTextColor(enable_ ? text_color_ : text_disable_color_);
// 		dc.DrawText(text_, _tcslen(text_), &rcitem_, DT_LEFT);
// 		dc.SelectFont(oldfont);
// 		dc.SetTextColor(oldcolor);
	}
}